// run: $exec < input
#include <iostream>
#include <string>

std::string s;
int n;

int main()
{
	std::ios::sync_with_stdio(false);
	int T;
	std::cin >> T;
	for (int ti = 1; ti <= T; ti++) {
		std::cout << "Case #" << ti << ": ";

		std::cin >> s;
		n = s.size();

		int totc = 0, first = -1;
		for (int i = 0; i < n; i++) {
			if (s[i] == 'c') {
				if (first == -1) first = i;
				totc++;
			}
		}

		if (!totc) {
			std::cout << int(n/2) + (n&1) << '\n';
		} else {
			bool ok = true;
			int prev = first, ans = totc;
			for (int i = first + 1; i < n; i++) {
				if (s[i] == 'c') {
					if (i - prev - 1 < 2) {
						ok = false;
						break;
					}
					prev = i;
				}
			}
			if (totc > 1 && first + n - prev - 1) ok = false;
			if (ok)
				std::cout << totc << '\n';
			else
				std::cout << "-1\n";
		}
	}
}
